<?php

use think\migration\Migrator;
use think\migration\db\Column;
use Phinx\Db\Adapter\MysqlAdapter;

class GroupActivityRewardTable extends Migrator
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
     *
     * The following commands can be used in this method and Phinx will
     * automatically reverse them when rolling back:
     *
     *    createTable
     *    renameTable
     *    addColumn
     *    renameColumn
     *    addIndex
     *    addForeignKey
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */
    public function change()
    {
        $table = $this->table('group_activity_reward');
        $table->addColumn('group_order_id','integer',array('limit' => MysqlAdapter::INT_REGULAR,'comment' => '拼团订单id'))->addIndex('group_order_id');
        $table->addColumn('order_id','integer',array('limit' => MysqlAdapter::INT_REGULAR,'comment' => '订单id'))->addIndex('order_id');
        $table->addColumn('user_id','integer',array('limit' => MysqlAdapter::INT_REGULAR, 'comment' => '用户id'))->addIndex('user_id');
        $table->addColumn('store_id','integer',array('limit' => MysqlAdapter::INT_REGULAR, 'comment' => '店铺id','default' => 0))->addIndex('store_id');
        $table->addColumn('group_activity_id','integer',array('limit' => MysqlAdapter::INT_REGULAR, 'comment' => '活动id'))->addIndex('group_activity_id');
        $table->addColumn('reward_type','integer',array('limit' =>  MysqlAdapter::INT_TINY, 'default' => 0, 'comment' => '奖励类型 0 直接发货  1 充值到余额 2 赠送积分 '));
        $table->addColumn('reward_value','string',array('limit' =>  100, 'default' => '', 'comment' => '奖励类型 0 直接发货  1 充值到余额 2 赠送积分 '));
        $table->addColumn('send_reward_type','integer',array('limit' =>  MysqlAdapter::INT_TINY, 'default' => 0, 'comment' => ' 1 成团立即发放 2 订单完成之后 '));
        $table->addColumn('status','boolean',array('limit' => 1,'default'=> 0, 'comment' => '状态 0 待发放 2 已发放 3 待审核'));
        $table->addTimestamps('create_time','update_time');
    }
}
